Set cellpadding and cellspacing in CSS?
Set cellpadding and cellspacing in CSS?
245
24-Apr-2023
Updated on 25-Apr-2023
Aryan Kumar
25-Apr-2023In HTML, `cellpadding` and `cellspacing` are attributes that are used to control the spacing between table cells. However, they are not CSS properties and cannot be set using CSS.
Instead, you can use CSS to control the spacing between table cells by setting the `border-spacing` or `border-collapse` properties on the table element. Here's an example:
In this example, we're setting the `border-spacing` property to `10px`, which will create a 10-pixel gap between adjacent cells in the table. We're also setting the `border-collapse` property to `separate`, which ensures that the borders between cells are visible.
Note that `border-spacing` is a shorthand property for setting both the horizontal and vertical spacing between cells. If you need to set different horizontal and vertical spacing, you can use the `border-spacing` property with two values, like this:
Again, note that `cellpadding` and `cellspacing` are not CSS properties and cannot be set directly with CSS.